package huanzhao.erp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import huanzhao.erp.domain.entity.Notification;
import huanzhao.erp.domain.entity.NotificationCore;
import org.apache.ibatis.annotations.Param;

import java.util.List;


public interface NotificationMapper extends BaseMapper<Notification> {

    /**
     * 按条件查询通知消息
     *
     * @param recipientId 接收者id
     * @param type        消息类型
     * @return List<Notification>
     * 2024/6/13 下午9:17:47
     */
    IPage<Notification> getNotificationsByCondition(@Param("recipientId") Long recipientId,
                                                    @Param("type") String type, IPage<?> page);

    /**
     * 获取未推送的通知
     *
     * @param recipientId 接收者id
     * @param limit       限制数量
     * @return List<Notification>
     * 2024/6/21 下午1:48:19
     */
    List<Notification> getUnpushedNotificationsInLimit(@Param("recipientId") long recipientId, @Param("limit") long limit);

    /**
     * 获取未推送的通知数量
     *
     * @param recipientId 接收者id
     * @return long
     * 2024/6/21 下午9:51:13
     */
    long getUnpushedNotificationsCount(@Param("recipientId") long recipientId);

    /**
     * 获取未读通知数量
     *
     * @param recipientId 消息接收方id
     * @return Long
     * 2024/7/4 下午2:46:12
     */
    Long getUnreadNotificationsCount(@Param("recipientId") Long recipientId);

    /**
     * 检查是否已经发送了相关的通知
     *
     * @param relatedId 任务id或手机id
     * @param type      通知类型
     * @return boolean
     * 2024/7/28 下午6:18:51
     */
    boolean isNotified(@Param("relatedId") Long relatedId, @Param("type") String type);

    NotificationCore getNotificationCoreInfoById(@Param("coreInfoId") Long coreInfoId);

    /**
     * 已读所有通知
     *
     * @param recipientId 接收者id
     * @return 2024/6/13 下午9:08:27
     */
    void readAllNotifications(@Param("recipientId") Long recipientId);

    /**
     * 已读通知
     *
     * @param id          通知id
     * @param recipientId 接收者id
     * @return void
     * 2024/6/13 下午9:12:19
     */
    void readNotification(@Param("id") Long id, @Param("recipientId") Long recipientId);

    /**
     * 将目标消息标记为已推送
     *
     * @param recipientId 接收者id
     *                    2024/6/21 下午10:09:31
     */
    void pushedNotifications(@Param("recipientId") long recipientId);

    /**
     * 添加通知
     * <p>
     * 2024/6/22 下午1:10:33
     */
    void addNotification(@Param("recipient_id") long recipient_id, @Param("core_info_id") long core_info_id, @Param("pushed") boolean pushed);

    /**
     * 添加通知核心信息
     *
     * @param coreInfo 通知核心信息
     *                 <p>
     *                 2024/10/2 22:02:45
     */
    void addNotificationCoreInfo(NotificationCore coreInfo);
}




